<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1.登录 显示隐藏内容</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        header {
            width: 500px;
            margin: 0 auto;
            overflow: hidden;
        }

        .username,
        .password {
            float: left;
            width: 130px;
            height: 25px;
            border: 1px solid #ccc;
            outline: 0;
            margin-top: 10px;
            margin-left: 8px;
            padding-left: 10px;
        }

        input::placeholder {
            color: #999;
        }



        button {
            width: 70px;
            height: 27px;
            margin-top: 10px;
            margin-left: 5px;
            font-size: 15px;
            background-color: rgb(113, 205, 241);
            border: 0;
            color: #fff;
        }
    </style>
</head>
<!-- 用户名和密码输入框 -->
<!-- 密码可显示隐藏 -->
<!-- 选中框后边框高亮 -->

<body>
    <header>
        <input type="text" placeholder="邮箱/ID/手机号" class="username">
        <input type="password" placeholder="密码" class="password">
        <button>登录</button>
    </header>
    <script>
        var username = document.querySelector('.username');
        var password = document.querySelector('.password');
        username.onfocus = function () {
            if (this.placeholder === '邮箱/ID/手机号') {
                this.placeholder = '';
            }
            this.style.color = '#333';
            this.style.borderColor = 'pink'
        }
        username.onblur = function () {
            if (this.placeholder === '') {
                this.placeholder = '邮箱/ID/手机号';
            }
            this.style.color = '#999';
            this.style.borderColor = ''
        }
        password.onfocus = function () {
            if (this.placeholder === '密码') {
                this.placeholder = '';
            }
            this.style.color = '#333';
            this.style.borderColor = 'pink'
        }
        password.onblur = function () {
            if (this.placeholder === '') {
                this.placeholder = '密码';
            }
            this.style.color = '#999';
            this.style.borderColor = ''
        }
    </script>
</body>

</html>